#ifndef ACCEPTOR_H
#define ACCEPTOR_H

#pragma once
#include "pub.hpp"
#include <functional>
class Acceptor
{
public:
    Acceptor(EventLoop* loop, const std::string& ip, 
        const unsigned short port);
    ~Acceptor();
    void setAcceptCb(std::function<void(Socket*)> cb) {
        acceptCb_ = cb;
    }
private:
    EventLoop* loop_ = nullptr;
    Socket* serverSock_ = nullptr;
    Channel* serverCh = nullptr;

    std::function<void(Socket*)> acceptCb_;
    
    // 当有客户端连接
    void newConnection();
};

#endif